package com.lcd.ssm.service.impl;

import com.lcd.ssm.domain.Permission;
import com.lcd.ssm.mapper.PermissionMapper;
import com.lcd.ssm.page.PageResult;
import com.lcd.ssm.query.QueryObject;
import com.lcd.ssm.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class PermissionServiceImpl implements IPermissionService {
    @Autowired
    private PermissionMapper permissionMapper;


    @Override
    public int deleteByPrimaryKey(Long id) {
        return permissionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Permission record) {
        return permissionMapper.insert(record);
    }

    @Override
    public Permission selectByPrimaryKey(Long id) {
        return permissionMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Permission> selectAll() {
        return permissionMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Permission record) {
        return permissionMapper.updateByPrimaryKey(record);
    }


    @Override
    public PageResult queryForPage(QueryObject qo) {
        Long count=permissionMapper.queryPageCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.emptyList());
        }
        List<Permission> list=permissionMapper.queryPage(qo);
        return new PageResult(count.intValue(),list);
    }


}
